package com.ibeeking.found.cop.b.rest.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.cop.b.rest.service.ICopChannelService;
import com.ibeeking.found.cop.service.common.param.CopChannelParam;
import com.ibeeking.found.cop.service.common.query.CopChannelPageQuery;
import com.ibeeking.found.cop.service.common.query.CopChannelQuery;
import com.ibeeking.found.cop.service.common.vo.CopChannelVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName CopChannelController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/channel/v1")
public class CopChannelController {

    @Resource
    private ICopChannelService copChannelServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询渠道列表")
    @PostMapping(value = "/list")
    public List<CopChannelVO> list(@RequestBody CopChannelQuery query) {
        return copChannelServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询渠道分页列表")
    @PostMapping(value = "/pageList")
    public Page<CopChannelVO> pageList(@RequestBody CopChannelPageQuery pageQuery) {
        return copChannelServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加渠道")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) CopChannelParam param) {
        return copChannelServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改渠道")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) CopChannelParam param) {
        return copChannelServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/changeStatus/{id}/{status}")
    public Boolean changeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return copChannelServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看渠道详情")
    @GetMapping(value = "/view/{id}")
    public CopChannelVO view(@PathVariable("id") Long id) {
        return copChannelServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除渠道")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return copChannelServiceImpl.del(id);
    }

}
